<?php 

	$id=$_POST['id'];
	$pw=$_POST['password'];

	//到数据库进行验证
	$link=mysql_connect("localhost","root",'');
	if (!$link) {
		die("连接失败".mysql_errno());
	}
	mysql_query("set names utf8;",$link) or die(mysql_errno());
	mysql_select_db('empManage',$link) or die(mysql_errno());
	
	$sql='select password,name from admin where id='.$id.';';

	$res=mysql_query($sql,$link);


	if ($row=mysql_fetch_assoc($res)) {

		if ($row['password']==md5($pw)) {

			$name=$row['name'];
			header("location:empMain.php?name=".$name);
			exit();
		}
		header("location:login.php?errno=2");
		exit();
	}else{
		header("location:login.php?errno=1");
		exit();
	}

	//关闭资源
	mysql_free_result($res);
	mysql_close($link);





	/*if ($id=='100') {
		if ($pw=='123') {
			header("location:empMain.php");
			exit();
		}
		header("location:login.php?errno=2");
		exit();
	}
	header("location:login.php?errno=1");
	exit();
*/

	
		
	
	




?>